<template>
	<section class="autoinsuranAll">
		<header class="bbtm rela wallfff" v-if="$store.state.Type">

			<h1 class="sz36 hue333 flex_core fontwt hei100">车险申报</h1>
			<router-link to="/mycentreAll/myauto" class="h_">
				<span class="sz30 hue999">我的车险</span>
			</router-link>
		</header>
		<figure class="l_h0">
			<img class="w100" src="../../assets/AutoInsuran/chexian_banner.png" alt="车险banner" />
		</figure>
		<section class="mu10">
			<h1 class="hue333 p30 sz28">
				请输入车主、车辆信息 <span class="hue999">（只支持私家车）</span>
			</h1>
			<ul class="wallfff">
				<li class="hei100 flex_between plr30 bbtm">
					<label for="num" class="flex_self sz30 w25">车牌号码</label>
					<input id="num" v-model="num" type="text" class="flex1 sz30" placeholder="请输入车牌号码" />
				</li>
				<li class="hei100 flexs plr30 bbtm">
					<label for="name" class="flex_self sz30 w25">姓名</label>
					<input id="name" v-model="name" type="text" class="flex1 sz30" placeholder="请输入车主姓名" />
				</li>
				<li class="hei100 flexs plr30 ">
					<label for="idcar" class="flex_self sz30 w25">身份证号码</label>
					<input id="idcar" v-model="idcar" type="text" class="flex1 sz30" placeholder="请输入车主身份证号码" />
				</li>
			</ul>
			<p class="p30 sz25 ">
				<i class="iconfont icon-xuanzhong hue7bf"></i>
				<span>我已经理解并阅读</span>
				<router-link to="/autoinsuranAll/autoterm" class="hue7bf">《车油宝平台服务条款》</router-link>
			</p>
		</section>

		<button class="btns btn_top" @click="next">
				下一步
			</button>

		<footers></footers>
	</section>
</template>
<script type="text/javascript">
	import { Toast } from 'mint-ui';
	import footers from '../../components/Other/footers'
	export default {
		name: 'autoinsuran',
		components: {
			footers
		},
		data() {
			return {
				num: "", // 车牌号
				name: "", // 姓名
				idcar: "" // 身份证
			}
		},
		created() {
			if(!this.$store.state.MembersID) {
				this.$router.push({
					path: '/LoginAll/ToLogin'
				})
			}
		},
		methods: {
			next: function() {
				let v = this,
					nums = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/,
					names = /^[\u4e00-\u9fa5]{2,}$/,
					idcars = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
				if(!nums.test(v.num)) {
					Toast("请输入正确车牌号")
				} else if(!names.test(v.name)) {
					Toast("请输入正确姓名")
				} else if(!idcars.test(v.idcar)) {
					Toast("请输入18位身份证号码")
				} else {
					document.body.style.background = "#fff";
					v.$parent.numbers = v.num;
					v.$parent.name = v.name;
					v.$parent.id = v.idcar;
					v.$router.push({
						path: '/autoinsuranAll/autoapply'
					})
				}

			},
		}
	}
</script>
<style scoped>
	.btn_top{
		margin-top: 1.0666666666rem;
	}
</style>